<? 
/***************************************************************************
 *                                 index.php
 *                           --------------------
 *   begin                : Friday, Aug 19, 2005
 *   copyright            : (C) 2005 cyber8 netWorks
 *   email                : support@cyber8.net 
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/
 
 
include ("includes/actions/act_xml_parser.php");
include ("includes/actions/act_methods.php");
include ("includes/actions/act_folder_parser.php");
include ("includes/actions/act_header.php");

/* BEGIN HTML OUTPUT
 --------------------------------------------------------- */ 
print "<html>"; 
print "<title>PIMP - ".($filename==""?$dirname:filetitle($filename))."</title>"; 
 
if (!$is_blackberry) 
{
    print "<style>body, td {font:7pt verdana}";
	print "input {font:8pt verdana;border-width:1px}"; 
	print "a {text-decoration:none;color:black}"; 
	print "a.line {text-decoration:underline;color:}"; 
	print "a.line:hover {text-decoration:none}"; 
	print "a:hover {text-decoration:underline}"; 
	print ".padded {padding:2px} .preload {width:32;height:32;overflow:hidden;color:whitesmoke}"; 
	print ".outset {border-right:solid 1px gray;border-bottom:solid 1px gray;"; 
	print "border-top:solid 1px gainsboro;border-left:solid 1px gainsboro;padding:2px}";  
	print "</style>"; 
	
    $client_script    = "";
    $client_variables = array ("DIRNAME" => $dirname,
	                          "ISMEDIA" => $is_media===true?'true':'false',
	                          "ISADMIN" => $is_admin===true?'true':'false',
	                          "ISPDA" => $is_pocketpc===true?'true':'false',
	                          "ISSERVICE" => $is_service===true?'true':'false',
	                          "EDITMODE" => $edit,
	                          "VIEWMODE" => $view,
	                          "WINDOWOFFSET" => $window_height_offset,
	                          "SCROLLLEFT" => $scroll,
	                          "SCROLLTOP" => $sc_t,
	                          "RESIZEFLAG" => $r ,
	                          "DORESIZE" => $r==='on'?'true':'false',
	                          "PATH" => "",
	                          "FILE" => $filename,
	                          "PASSWORD" => $qp,
	                          "SIDEBARMODE" => $hm,
	                          "PARENT" => $this_folder->pimp_parentfolder,
	                          "WINDOWKEY" => $ql,
	                          "CONTINUOUS" => $cc,
	                          "MEDIASIZE" => $mz,
	                          "PREVIEWFLAG" => $pv,
	                          "GRIDFLAG" =>  $dg,
	                          "SHOWMETRICS" =>  "false"); 
    while (list ($key, $val) = each ($client_variables))   
	{
	    $script_delim   = $val=="true"||$val=="false"?"":"\"";
		$client_script .= "$key=$script_delim$val$script_delim;";
	}
	print script_block ($client_script);
	print script_block ("", CLIENT_JS_XML);
	print script_block ("", CLIENT_JS_AUTOCOMPLETE);
	print script_block ("", CLIENT_JS_MAIN); 
}  
 

/* BEGIN page pre-processing 
 ----------------------------------------------------------- */
if (strlen($master)>0) 
{ // check for admin log in
    if ($qm==$pvmaster) 
	{ 
		$is_admin = true;
	}
	else 
	{ // admin log in form
		include ("includes/forms/frm_master_login.php");
	} 
}
 
// check for folder log in
if (($this_folder->pimp_secure)&&($qp!=$this_folder->pimp_folder_password)&&(!$is_pocketpc)) 
{ // folder log in form 
	include ("includes/forms/frm_folder_login.php"); 		 
}
		 
  

/* BEGIN body tag
 ----------------------------------------------------------- */


print "<body topmargin='0' leftmargin='1' style='border:solid 1px #99CCFF";
if (!$is_pocketpc) 
{
	print ";overflow:hidden' scroll='no' onload='sizepic()'";
}
else 
{
	print "'";
} 
if ($is_blackberry) 
{
	print " bgcolor='#FFFFFF'";
}
else if ($edit!="") 
{
	print " bgcolor='#99CCFF'";
} 
print ">";

// workspace
print "<table bgcolor=white cellspacing='0' cellpadding='0' width='100%' id='mainwindow'>";
print "<tr>";
print "<td colspan='3' nowrap >";
if ($edit=="e") 
{ // container for EDITOR open documents
	print "<div id='dfilelist'";
	print " style='width:expression(document.body.offsetWidth);height:50;overflow:auto'";
	print "></div>";
}
if (!$is_blackberry) 
{
	include ("includes/displays/dsp_toolbar.php");
}
print "</td></tr>";	
print "<tr><td colspan='3' nowrap bgcolor='#0099CC'><img src='$href?i=px' height='1'></td></tr>";
print "<tr><td colspan='3' nowrap bgcolor=white><img src='$href?i=px' height='1'></td></tr>";
print "<tr>";	
$window_height_offset += $toolbar_height_offset;		

 
$window_width_offset = 0;
if ($fo=="on") 
{ // TREEVIEW container
	if ($sw=="") 
	{
		$sw=180;
	}
	$req = "<files selected='".($rm_d==""?$dirname:$rm_d)."'>n";
	$req .= "  <folder>n";
	$req .= "    <path>".$pathdata[1]."</path>n";
	$req .= "    <name>".filetitle($pathdata[1])."</name>n";
	$req .= "    <type>File Folder</type>n";
	$req .= gen_folder_markup($pathdata[1],$dirname,$rm_d,"");
	$req .= "  </folder>n";
	$req .= "</files>"; 
	$treeview = sendToPHPDc ("www.cyber8.net", "POST", "/webservices/treeview_transform.asp", $req, 0);
	
	
	print "<td valign=top>"; 
	print "<div style='cursor:hand;background-color:#99CCFF;width:100%' align=right onclick=\"fb_edit('fo','')\">"; 
	print "<u>Folders</u><font face='webdings'>r</font></div>";
	print "<div align='left' class='resizeY' id='dtreeview' "; 
	print "style='width:".$sw.";height:expression(document.body.offsetHeight-40);"; 
	if (!$is_pocketpc) 
	{
		print "overflow:auto;border:solid 1px gray"; 
	}
	print "'>";
	print "<table><tr><td nowrap valign=top>";
	print $treeview;		
	print "</td></tr></table></div></td>";
	$window_width_offset += $sw;
} // TREEVIEW container
 


// container for SIDEBAR CONTROLS
if (!$is_pocketpc) 
{
	print "<td nowrap align=center valign=top";
	if (($edit!="")&&($hm=="")) 
	{
		print " width=200 ";
	}
	if ($edit=="e") 
	{
		print " bgcolor='#99CCFF' ";
	}
	if ($hm=="1") 
	{
		print " bgcolor='#99CCFF' ";
		print "><div align=right style='cursor:hand;' onclick=\"fb_edit('hm','')\"><font face='webdings'>1</font></div>";
		print "<div style='display:none' id='dinfopanels'>"; 
		$window_width_offset+=20;
	} 
	else 
	{
		print "><div align=right";
		print " style='cursor:hand;background-color:#99CCFF;margin-bottom:3px'";
		print " onclick=\"fb_edit('hm','1')\"><u>Info Panels</u><font face='webdings'>r</font></div><div style='' id='dinfopanels'>"; 
		$window_width_offset+=210;
	}  

	if ($edit=="e") 
	{
		include ("includes/displays/dsp_edit_controls.php");
	}
	else if ($edit!="") 
	{
		include ("includes/displays/dsp_file_controls.php");  
	}
	print "</div></td>"; // SIDEBAR CONTROLS 
}  

if (($edit=="e")||($edit=="t")) 
{ // implement client DOCUMENT INSTANCE objects  
	$arrconfig = file_to_array($editconfig);
	parse_str($arrconfig[0]);
	for ($k=1;$k<count($arrconfig);$k++) 
	{
		$text="";
		$file="";
		parse_str($arrconfig[$k]); 
		if ($text==""&&$edit=="e") 
		{
			$active = $file==$selected?"true":"false"; ?> 
			<script language="javascript">
			i = new editedfile ("<?= $name ?>","<?= $file ?>","<?= $zoom ?>",<?= $active ?>); 
			instance[instance.length]=i;
			instance["<?= $name ?>"]=i;
			</script><?  // client script will build the IMAGE EDITOR file menu
		} 
		else if ($edit=="t")  
		{ 			
			$active = $mfile==""&&$text==$selected?"true":"false";
			if (!(strpos($mfile,$text)===false)) $active=true; ?> 
			<script language="javascript">
			i = new textfile ("<?= $name ?>","<?= $text ?>",<?= $active ?>); 
			instance[instance.length]=i;
			instance["<?= $name ?>"]=i;
			</script><?  // client script will build the TEXT EDITOR file menu 
		}
	}
} 


print "<td valign=top>"; // WORKSPACE cell		
if (!(($fo=="on")&&($is_pocketpc))) 
{ // pocket pc can only see one pane at a time
	print "<div class='resizeXY'  id='dworkspace'";   // PREVIEW PANE container
	if ($edit!="") 
	{
		if ($is_pocketpc) 
		{
			print "style='width:225;"; 
		}
		else 
		{
			print "style='width:expression(document.body.offsetWidth-".$window_width_offset.");"; 
		}
		print "height:expression(document.body.offsetHeight-".$window_height_offset.");";
		print "background-color:#FFFFFF;border:dotted 1px whitesmoke;";
		if (!(($view!="")||$is_admin)) 
		{
			print "overflow:auto"; 
		}
		print "'";
	} 
	if (!$is_blackberry) 
	{
		print " align='center'"; 
	} 
	if ($edit=="e") 
	{
		print " onscroll = 'edit_scroll()'";  
	}
	print ">"; // end div/layer spec for preview pane container
	
	// BEGIN MAIN WORKSPACE TABLE 
	print "<table width='100%' cellpadding='1' cellspacing='1'";
	if ($edit=="e"||$view=="") 
	{
		print " height=100%";
	}
	print "><tr><td>";		 
	 
	// center workspace ------------------------------------  
	if ($edit=="")
	{ // home page
	  //  include ( "includes/displays/dsp_splash_page.php" );       
	  response_redirect ("$href?e=b&l=k&d=$dirname&r=on&qp=$qp")    ;        
	}
	else if ($edit=="t") 
	{ // text editor
		include ( "includes/displays/" . ($is_pocketpc?"dsp_view_details.php":"dsp_view_editor.php") );
	}
	else if ($is_admin)  
	{ // admin form
		include ( "includes/displays/dsp_view_admin.php" );                   
	}
	else if ($view=="d"||$view=="t") 
	{ // detail view
		include ( "includes/displays/dsp_view_details.php" );                 
	}
	else if ($page_file["type"]=="mpg")  
	{ // media player for filmstrip view
		include ( "includes/displays/dsp_view_media.php" );   
	}
	else if (strlen($filename)>0) 
	{ // center image for all other views
		print "<center><img src='gen.jpg' id='mainpic'></center>";   
	}
	// center workspace ------------------------------------   		
	
	print "</td></tr></table>"; // END WORKSPACE table  
	print "</div>"; // END PREVIEW PANE container  	
	
	// (optional) FILMSTRIP container
	include ("includes/displays/dsp_view_film.php"); 
} 
print "</td>"; // WORKSPACE cell	 
print "</tr></table>"; // END main table

// hidden divs
print "<div id=editworkspace style='position:absolute;top:0;";
print "left:0;filter:alpha (opacity=2)'></div>";
print "<div id=splittertree class='splitter_dtreeview_Y' style='position:absolute;top:0;";
print "left:0;background-color:#99CCFF;cursor:e-resize'></div>";
print "<div id=wsborder style='position:absolute;top:0;left:0;";
print "border:solid 1px white;padding:2px;display:none'></div>";
print "</body>";
/* END body tag
 ----------------------------------------------------------- */
print "</html>"; 
 

?>

